<?php
/* @var $this ShiftChangeController */
/* @var $model ShiftChange */

$this->pageTitle=Yii::app()->name . ' - Shift Change Management';
$this->breadcrumbs=array(
	'Shifts'=>array('/shift/'),
	'Change Management',
);

$this->menu=array(
	//array('label'=>'List ShiftChange', 'url'=>array('index')),
	array('label'=>'Create Shift Change', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#shift-change-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Shift Change Management</h1>


<?php 
/*
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>


 echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
*/ ?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'shift-change-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		//'idshift_change',
		array(
			'name'=>'requesting_user',
			'header'=>'Requestor',
			'filter'=>CHtml::listData(User::model()->findAll(array('order'=>'username ASC','condition'=>'team =' . $model->team_id)),
																		 'iduser',
																		 'username'
																		 ),	
			'value'=>'$data->requestingUser_relation->username',
			'htmlOptions' => array(
								'style' => 'width:80px; text-align:center;',
							 ),
		),			
		array(
			'name'=>'current_shift',
			'header'=>'Requestor\'s Shift',
			'filter'=>'',			
			'value'=>'$data->getCurrentShift()',
			'htmlOptions' => array(
								'style' => 'width:80px; text-align:center;',
							 ),
		),					
		array(
			'name'=>'requested_shift',
			'header'=>'Requested Shift',
			'filter'=>'',		
			'value'=>'$data->requestedShift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:80px; text-align:center;',
							 ),
		),						
		array(
			'name'=>'requested_qshift',
			'header'=>'Requested QShift',
			'filter'=>'',		
			'value'=>'$data->requestedQshift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:80px; text-align:center;',
							 ),
		),					
			
		array(
			'name'=>'day_requested',
			'header'=>'Date',
			'value'=>'$data->day_requested',
			'htmlOptions' => array(
								'style' => 'width:70px; text-align:center;',
							 ),
		),						
		array(
			'name'=>'request_status',
			'header'=>'Status',
			'value'=> 'ShiftChange::getStatus($data->request_status)',
			'filter' => array('1'=>'Approved', '2'=>'Denied','3'=>'Pending','4'=>'Pending Cancel','5'=>'Cancelled'),
			'htmlOptions' => array(
								'style' => 'width:80px;text-align:center;',
							 ),
		),	
		array(
			'name'=>'target_user',
			'header'=>'Target User',
			'filter'=>CHtml::listData(User::model()->findAll(array('order'=>'username ASC','condition'=>'team=' . $model->team_id)),
																		 'iduser',
																		 'username'
																		 ),	
			'value'=> '$data->getTargetUser()', //'($data->targetUser_relation->username)',
			'htmlOptions' => array(
								'style' => 'width:80px; text-align:center;',
							 ),
		),	
		
		/*	
		'comments',
		'team_id',
		*/
		array(
			'class'=>'CButtonColumn',
			'header'=>'Actions',
			'template'=>'{view}{delete}',
			'deleteConfirmation'=>'Are you sure you want to CANCEL this Shift Change?',
			'buttons'=>array(
						'view'=>array(
									'url'=>'Yii::app()->createUrl("shiftChange/view", array("id"=>$data->idshift_change))',
									'label'=>'View Change',
									'options' => array('style'=>'width:10px;','title'=>'View Details')
						          ),
						'delete'=>array(
									'url'=>'Yii::app()->createUrl("shiftChange/cancel", array("id"=>$data->idshift_change))',
									'label'=>'Cancel Change',
									'visible'=> '$data->isStatusCancellable($data->day_requested)',
									'options' => array('style'=>'width:10px;','title'=>'Cancel Shift Change')
						          ),
						
					   ),			
		),	
	),
)); ?>
